import System.Directory qualified as SysD
import System.Process qualified as SysP
import Text.Printf qualified as TextP

main :: IO ()
main = do
  test1
  prtSep
  test2

-- 打印分隔符
prtSep :: IO ()
prtSep = putStrLn "=============================="

-- 打印当前目录内容
test1 :: IO ()
test1 = do
  SysD.setCurrentDirectory "."
  paths <- SysD.getDirectoryContents "."
  case paths of
    [] -> putStrLn "not any files"
    as@(a : _) -> do
      TextP.printf "first file is %s\n" a
      putStrLn $ TextP.printf "files is\n %s\n" $ unlines as

-- 打印家目录内容
test2 :: IO ()
test2 = do
  homeDir <- SysD.getHomeDirectory
  a <- SysD.getDirectoryContents homeDir
  putStrLn $ unlines $ a